﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace PFAGame
{
    class ArcadeMenuScreen : MenuScreen
    {
         #region Fields

        MenuEntry characterGameMenuEntry;

        static string[] character = { "Frank", "Suzie" };
        static int currentCharacter = 0;

        #endregion

        #region Initialization

        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public ArcadeMenuScreen()
            : base("Survival Mode")
        {
            // Create our menu entries.
            characterGameMenuEntry = new MenuEntry(string.Empty);
            MenuEntry joinGameMenuEntry = new MenuEntry("Start");
            MenuEntry backMenuEntry = new MenuEntry("Back");

            SetMenuEntryText();

            // Hook up menu event handlers.
            characterGameMenuEntry.Selected += CharacterChoice;
            joinGameMenuEntry.Selected += JoinGameMenuEntrySelected;
            backMenuEntry.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(characterGameMenuEntry);
            MenuEntries.Add(joinGameMenuEntry);
            MenuEntries.Add(backMenuEntry);
        }

        void SetMenuEntryText()
        {
            characterGameMenuEntry.Text = "Character : " + character[currentCharacter];
        }

        #endregion

        #region Handle Input

        void CharacterChoice(object sender, PlayerIndexEventArgs e)
        {
            currentCharacter = (currentCharacter + 1) % character.Length;

            SetMenuEntryText();
        }

        /// <summary>
        /// Event handler for when the Play Game menu entry is selected.
        /// </summary>
        void JoinGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            e_class playerClass = currentCharacter == 0 ? e_class.BOURRIN : e_class.SPECIALISTE;
            LoadingScreen.Load(ScreenManager.Singleton, true, e.PlayerIndex, new GameplayScreen(null, playerClass, e_GameMode.SURVIVAL, 1, 0));
        }

        #endregion
    }
}
